package com.cosmoplat.gfqd.config;

import org.yaml.snakeyaml.Yaml;
import java.io.InputStream;

public class ConfigLoader {

    public static BootStrapConfig loadConfig(String fileName) {
        Yaml yaml = new Yaml();
        try (InputStream inputStream = ConfigLoader.class
                .getClassLoader()
                .getResourceAsStream(fileName)) {
            if (inputStream != null) {
                return yaml.loadAs(inputStream, BootStrapConfig.class);
            } else {
                throw new RuntimeException("Unable to find " + fileName);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
